package com.zhl.media.login.mvp.model.api.service;

import com.zhl.media.commonsdk.data.UserUtil;
import com.zhl.media.commonsdk.entity.Token;

import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;

import static com.zhl.media.login.mvp.model.api.Api.LOGIN_DOMAIN_NAME;
import static me.jessyan.retrofiturlmanager.RetrofitUrlManager.DOMAIN_NAME_HEADER;

public interface LoginService {
    /**
     * 获取token
     */
    @FormUrlEncoded
    @POST("oauth/token")
    @Headers({"Content-Type:application/x-www-form-urlencoded", "Authorization:Basic YnJvd3Nlcjo=",DOMAIN_NAME_HEADER + LOGIN_DOMAIN_NAME})
    Observable<Token> getToken(@Field("username") String username, @Field("password") String password, @Field("grant_type") String grant_type);

    //获取用户信息
    @GET("users/current")
    @Headers({DOMAIN_NAME_HEADER + LOGIN_DOMAIN_NAME})
    Observable<Object> getUserInfo();
}
